package com.chuantou.yuba.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

import com.chuantou.yuba.R;
import com.chuantou.yuba.ui.fragment.NearFishingFragment;
import com.chuantou.yuba.util.AccountManager;
import com.chuantou.yuba.util.UiUtil;

public class NearFishingActivity extends BaseActionBarActivity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.fragment_layout);
		NearFishingFragment fragment = new NearFishingFragment();
		getSupportFragmentManager().beginTransaction().add(R.id.content, fragment).commit();
		setTitle(R.string.fishing);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.menu_send_fishing, menu);
		return super.onCreateOptionsMenu(menu);
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case R.id.menu_send_fishing:
			AccountManager accountManager = AccountManager.getInstance(getApplicationContext());
			if (!accountManager.isLogined()) {
				UiUtil.showNoLoginDialog(this, -1, LoginActivity.ACTION_RETURN);
				return false;
			}
			// 发送约钓界面
			Intent intent = new Intent(this, PublishFishingActivity.class);
			startActivity(intent);
			return true;

		default:
			break;
		}
		return super.onOptionsItemSelected(item);
	}
}
